import {Script, Word, Dictionary,OpCode} from './compiler.ts';
import * as path from 'https://deno.land/std@0.95.0/path/mod.ts';
import {
    exists,
  } from "https://deno.land/std@0.95.0/fs/mod.ts";
export class PathDictionary implements Dictionary {
    constructor(private path:string){
    }
    async lookup(word:string):Promise<Word|undefined> {
        const filename = path.join(this.path, word+'.forth');
        if (!await exists(filename)) return undefined;
        const text = await Deno.readTextFile(filename);
        return new Script(text);
    }
}